import jsonpickle as jp


# 压缩普通对象
def encode(obj) -> str:
    if not obj:
        return ""

    return jp.encode(obj)


# 压缩 UTF-8 对象
def encode_utf8(obj) -> str:
    if not obj:
        return ""

    return encode(obj).encode('utf-8').decode('unicode_escape')


# 解压普通对象
def decode(json: str):
    if not json:
        return None

    return jp.decode(json)
